from sqlalchemy import Column, String, Integer, DateTime, DECIMAL
from sqlalchemy.orm import declarative_base

from x_pc.db.source import Session

Base = declarative_base()


class DeliveryWorkQueue(Base):
    """
    CREATE TABLE `wops_delivery_work_queue` (
      `task_id` varchar(32) NOT NULL COMMENT '母任务编号',
      `parent_task_id` varchar(255) DEFAULT NULL COMMENT '上级任务，无上级任务则为空，多个上级任务用逗号分隔',
      `command_type_code` varchar(32) NOT NULL COMMENT '指令类型编号',
      `command_group_code` varchar(32) NOT NULL COMMENT '指令组编号',
      `lpn` varchar(32) NOT NULL COMMENT '作业LPN',
      `is_urgent` int(10) DEFAULT NULL COMMENT '急料标识',
      `sku` varchar(32) NOT NULL COMMENT '物料sku',
      `origin_sku_num` int(10) NOT NULL COMMENT '初始PCS数',
      `target_sku_num` int(10) NOT NULL COMMENT '最终PCS数',
      `origin_pack_type` int(10) NOT NULL COMMENT '开始物料类型',
      `target_pack_type` int(10) NOT NULL COMMENT '结束物料类型',
      `origin_loc` varchar(32) NOT NULL COMMENT '开始货位',
      `origin_loc_template_detailid` varchar(32) DEFAULT NULL COMMENT '开始货位货格（针对柔性货位使用）',
      `state` int(10) NOT NULL COMMENT '工单状态\r\n工单状态1 新建、 2:已排程、3、已下发、4已完成、5已取消',
      `plan_begin` datetime DEFAULT NULL,
      `plan_end` datetime DEFAULT NULL,
      `wops_wavelet_orderid` varchar(32) NOT NULL,
      `wops_command_unit_routeid` varchar(32) DEFAULT NULL COMMENT '作业路径编号',
      `wops_vehicle_taskid` varchar(32) NOT NULL COMMENT '发车任务编号',
      `wops_delivery_time_windowid` varchar(32) NOT NULL COMMENT '大波次编号',
      `time_window_start_time` datetime NOT NULL,
      `time_window_end_time` datetime NOT NULL,
      `vehicle_task_end_time` datetime NOT NULL COMMENT '装车结束时间',
      `vehicle_task_begin_time` datetime NOT NULL COMMENT '装车开始时间',
      `add_date` datetime NOT NULL COMMENT '创建日期',
      `edit_date` datetime NOT NULL COMMENT '编辑日期',
      `sim_plan_begin` datetime DEFAULT NULL,
      `sim_plan_end` datetime DEFAULT NULL,
      `deliver_factory_code` varchar(32) NOT NULL COMMENT '交付对象编码',
      `deliver_factory` varchar(32) NOT NULL COMMENT '交付对象',
      `template_id` varchar(32) DEFAULT NULL COMMENT '模版id',
      `loc_column` int(11) DEFAULT NULL COMMENT '货位列',
      `loc_row` int(11) DEFAULT NULL COMMENT '货位行',
      `packkey` varchar(50) DEFAULT NULL COMMENT '包规',
      `innerpack` decimal(22,5) DEFAULT NULL COMMENT '内包装换算率',
      `casecant` decimal(22,5) DEFAULT NULL COMMENT '件箱换算率',
      `pallet` decimal(22,5) DEFAULT NULL COMMENT '托盘换算率',
      PRIMARY KEY (`task_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='时间窗作业队列'
    """
    __tablename__ = 'wops_delivery_work_queue'

    task_id = Column(String(32), primary_key=True, comment='母任务编号')
    parent_task_id = Column(String(255), comment='上级任务，无上级任务则为空，多个上级任务用逗号分隔')
    command_type_code = Column(String(32), nullable=False, comment='指令类型编号')
    command_group_code = Column(String(32), nullable=False, comment='指令组编号')
    lpn = Column(String(32), nullable=False, comment='作业LPN')
    is_urgent = Column(Integer, comment='急料标识')
    sku = Column(String(32), nullable=False, comment='物料sku')
    origin_sku_num = Column(Integer, nullable=False, comment='初始PCS数')
    target_sku_num = Column(Integer, nullable=False, comment='最终PCS数')
    origin_pack_type = Column(Integer, nullable=False, comment='开始物料类型')
    target_pack_type = Column(Integer, nullable=False, comment='结束物料类型')
    origin_loc = Column(String(32), nullable=False, comment='开始货位')
    origin_loc_template_detailid = Column(String(32), comment='开始货位货格（针对柔性货位使用）')
    state = Column(Integer, nullable=False, comment='工单状态\r\n工单状态1 新建、 2:已排程、3、已下发、4已完成、5已取消')
    plan_begin = Column(DateTime, comment='计划开始时间')
    plan_end = Column(DateTime, comment='计划结束时间')
    wops_wavelet_orderid = Column(String(32), nullable=False)
    wops_command_unit_routeid = Column(String(32), comment='作业路径编号')
    wops_vehicle_taskid = Column(String(32), nullable=False, comment='发车任务编号')
    wops_delivery_time_windowid = Column(String(32), nullable=False, comment='大波次编号')
    time_window_start_time = Column(DateTime, nullable=False)
    time_window_end_time = Column(DateTime, nullable=False)
    vehicle_task_end_time = Column(DateTime, nullable=False, comment='装车结束时间')
    vehicle_task_begin_time = Column(DateTime, nullable=False, comment='装车开始时间')
    add_date = Column(DateTime, nullable=False, comment='创建日期')
    edit_date = Column(DateTime, nullable=False, comment='编辑日期')
    sim_plan_begin = Column(DateTime, comment='模拟计划开始时间')
    sim_plan_end = Column(DateTime, comment='模拟计划结束时间')
    deliver_factory_code = Column(String(32), nullable=False, comment='交付对象编码')
    deliver_factory = Column(String(32), nullable=False, comment='交付对象')
    template_id = Column(String(32), comment='模版id')
    loc_column = Column(Integer, comment='货位列')
    loc_row = Column(Integer, comment='货位行')
    packkey = Column(String(50), comment='包规')
    innerpack = Column(DECIMAL(22, 5), comment='内包装换算率')
    casecant = Column(DECIMAL(22, 5), comment='件箱换算率')
    pallet = Column(DECIMAL(22, 5), comment='托盘换算率')
    orderdetil = Column(String(256), comment='关联的订单编号')
    consigneekey = Column(String(15), comment='收货单位')
    lot = Column(String(256), comment='当前任务选中物料批次号')
    act_num = Column(Integer, comment='多dc栈板实际数量')


class InteriorWorkQueue(Base):
    """
    CREATE TABLE `wops_interior_work_queue` (
      `task_id` varchar(32) NOT NULL COMMENT '母任务编号',
      `parent_task_id` varchar(255) DEFAULT NULL COMMENT '上级任务，无上级任务则为空，多个上级任务用逗号分隔',
      `command_type_code` varchar(32) NOT NULL COMMENT '指令类型编号',
      `command_group_code` varchar(32) NOT NULL COMMENT '指令组编号',
      `lpn` varchar(32) NOT NULL COMMENT '作业LPN',
      `is_urgent` int(10) DEFAULT NULL COMMENT '急料标识',
      `sku` varchar(32) NOT NULL COMMENT '物料sku',
      `origin_sku_num` int(10) NOT NULL,
      `target_sku_num` int(10) NOT NULL,
      `origin_pack_type` int(10) NOT NULL COMMENT '开始物料类型',
      `target_pack_type` int(10) NOT NULL COMMENT '结束物料类型',
      `origin_loc` varchar(32) NOT NULL COMMENT '开始货位',
      `origin_loc_template_detailid` varchar(32) DEFAULT NULL COMMENT '开始货位货格（针对柔性货位使用）',
      `state` int(10) DEFAULT NULL COMMENT '工单状态\r\n工单状态1 新建、 2:已排程、3、已下发、4已完成、5已取消',
      `plan_begin` datetime DEFAULT NULL COMMENT '计划开始时间',
      `plan_end` datetime DEFAULT NULL COMMENT '计划结束时间',
      `wops_wavelet_orderid` varchar(32) DEFAULT NULL COMMENT '小波次编号',
      `wops_command_unit_routeid` varchar(32) DEFAULT NULL COMMENT '作业路径编号',
      `wops_vehicle_taskid` varchar(32) DEFAULT NULL COMMENT '发车任务编号',
      `wops_delivery_time_windowid` varchar(32) NOT NULL COMMENT '大波次编号',
      `time_window_start_time` datetime NOT NULL COMMENT '时间窗开始时间',
      `time_window_end_time` datetime NOT NULL COMMENT '世界窗结束时间',
      `vehicle_task_begin_time` datetime DEFAULT NULL COMMENT '装车开始时间',
      `vehicle_task_end_time` datetime DEFAULT NULL COMMENT '装车结束时间',
      `add_date` datetime NOT NULL COMMENT '创建日期',
      `edit_date` datetime NOT NULL COMMENT '编辑日期',
      `loc_column` int(11) DEFAULT NULL COMMENT '列',
      `loc_row` int(11) DEFAULT NULL COMMENT '货位行',
      `template_id` varchar(32) DEFAULT NULL COMMENT '模板编号',
      `deliver_factory_code` varchar(32) DEFAULT NULL,
      `deliver_factory` varchar(32) DEFAULT NULL,
      `packkey` varchar(50) DEFAULT NULL COMMENT '包规',
      `innerpack` decimal(22,5) DEFAULT NULL COMMENT '内包装换算率',
      `casecant` decimal(22,5) DEFAULT NULL COMMENT '件箱换算率',
      `pallet` decimal(22,5) DEFAULT NULL COMMENT '托盘换算率',
      `lot` varchar(32) NOT NULL COMMENT '当前任务选中物料批次号',
      `act_num` int(11) DEFAULT NULL COMMENT '多dc栈板实际数量',
      `cwmsinvtaskdetil` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '关联的订单编号',
      `consigneekey` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '收货单位',
      `is_out` varchar(32) DEFAULT NULL COMMENT '是否出过库U是出过库',
      PRIMARY KEY (`task_id`) USING BTREE
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='在库作业队列'
    """

    __tablename__ = 'wops_interior_work_queue'

    task_id = Column(String(32), primary_key=True, comment='母任务编号')
    parent_task_id = Column(String(255), comment='上级任务，无上级任务则为空，多个上级任务用逗号分隔')
    command_type_code = Column(String(32), nullable=False, comment='指令类型编号')
    command_group_code = Column(String(32), nullable=False, comment='指令组编号')
    lpn = Column(String(32), nullable=False, comment='作业LPN')
    is_urgent = Column(Integer, comment='急料标识')
    sku = Column(String(32), nullable=False, comment='物料sku')
    origin_sku_num = Column(Integer, nullable=False, comment='初始PCS数')
    target_sku_num = Column(Integer, nullable=False, comment='最终PCS数')
    origin_pack_type = Column(Integer, nullable=False, comment='开始物料类型')
    target_pack_type = Column(Integer, nullable=False, comment='结束物料类型')
    origin_loc = Column(String(32), nullable=False, comment='开始货位')
    origin_loc_template_detailid = Column(String(32), comment='开始货位货格（针对柔性货位使用）')
    state = Column(Integer, comment='工单状态\r\n工单状态1 新建、 2:已排程、3、已下发、4已完成、5已取消')
    plan_begin = Column(DateTime, comment='计划开始时间')
    plan_end = Column(DateTime, comment='计划结束时间')
    wops_wavelet_orderid = Column(String(32), comment='小波次编号')
    wops_command_unit_routeid = Column(String(32), comment='作业路径编号')
    wops_vehicle_taskid = Column(String(32), comment='发车任务编号')
    wops_delivery_time_windowid = Column(String(32), nullable=False, comment='大波次编号')
    time_window_start_time = Column(DateTime, nullable=False, comment='时间窗开始时间')
    time_window_end_time = Column(DateTime, nullable=False, comment='世界窗结束时间')
    vehicle_task_begin_time = Column(DateTime, comment='装车开始时间')
    vehicle_task_end_time = Column(DateTime, comment='装车结束时间')
    add_date = Column(DateTime, nullable=False, comment='创建日期')
    edit_date = Column(DateTime, nullable=False, comment='编辑日期')
    loc_column = Column(Integer, comment='列')
    loc_row = Column(Integer, comment='货位行')
    template_id = Column(String(32), comment='模板编号')
    deliver_factory_code = Column(String(32))
    deliver_factory = Column(String(32))
    packkey = Column(String(50), comment='包规')
    innerpack = Column(DECIMAL(22, 5), comment='内包装换算率')
    casecant = Column(DECIMAL(22, 5), comment='件箱换算率')
    pallet = Column(DECIMAL(22, 5), comment='托盘换算率')
    lot = Column(String(256), comment='当前任务选中物料批次号')
    act_num = Column(Integer, comment='多批次栈板实际数量')
    cwmsinvtaskdetil = Column(String(64), comment='关联的订单编号')
    consigneekey = Column(String(15), comment='收货单位')
    is_out = Column(String(32), comment='是否出过库U是出过库')

    def has_out(self) -> bool:
        """
        是否出过库
        :return:
        """
        return self.is_out and self.is_out.strip() in ('u', 'U')


class PreworkWorkQueue(Base):
    """
    CREATE TABLE `wops_prework_work_queue` (
      `task_id` varchar(32) NOT NULL COMMENT '母任务编号',
      `parent_task_id` varchar(255) DEFAULT NULL COMMENT '上级任务，无上级任务则为空，多个上级任务用逗号分隔',
      `command_type_code` varchar(32) NOT NULL COMMENT '指令类型编号',
      `command_group_code` varchar(32) NOT NULL COMMENT '指令组编号',
      `lpn` varchar(32) NOT NULL COMMENT '作业LPN',
      `is_urgent` int(10) DEFAULT NULL COMMENT '急料标识',
      `sku` varchar(32) NOT NULL COMMENT '物料sku',
      `origin_sku_num` int(10) NOT NULL,
      `target_sku_num` int(10) NOT NULL,
      `origin_pack_type` int(10) NOT NULL COMMENT '开始物料类型',
      `target_pack_type` int(10) NOT NULL COMMENT '结束物料类型',
      `origin_loc` varchar(32) NOT NULL COMMENT '开始货位',
      `origin_loc_template_detailid` varchar(32) DEFAULT NULL COMMENT '开始货位货格（针对柔性货位使用）',
      `state` int(10) DEFAULT NULL COMMENT '工单状态\r\n工单状态1 新建、 2:已排程、3、已下发、4已完成、5已取消',
      `plan_begin` datetime DEFAULT NULL COMMENT '计划开始时间',
      `plan_end` datetime DEFAULT NULL COMMENT '计划结束时间',
      `wops_wavelet_orderid` varchar(32) DEFAULT NULL COMMENT '小波次编号',
      `wops_command_unit_routeid` varchar(32) DEFAULT NULL COMMENT '作业路径编号',
      `wops_vehicle_taskid` varchar(32) DEFAULT NULL COMMENT '发车任务编号',
      `wops_delivery_time_windowid` varchar(32) NOT NULL COMMENT '大波次编号',
      `time_window_start_time` datetime NOT NULL COMMENT '时间窗开始时间',
      `time_window_end_time` datetime NOT NULL COMMENT '世界窗结束时间',
      `vehicle_task_begin_time` datetime DEFAULT NULL COMMENT '装车开始时间',
      `vehicle_task_end_time` datetime DEFAULT NULL COMMENT '装车结束时间',
      `add_date` datetime NOT NULL COMMENT '创建日期',
      `edit_date` datetime NOT NULL COMMENT '编辑日期',
      `loc_column` int(11) DEFAULT NULL COMMENT '列',
      `loc_row` int(11) DEFAULT NULL COMMENT '货位行',
      `template_id` varchar(32) DEFAULT NULL COMMENT '模板编号',
      `deliver_factory_code` varchar(32) DEFAULT NULL,
      `deliver_factory` varchar(32) DEFAULT NULL,
      `wops_prework_planid` varchar(32) NOT NULL,
      `packkey` varchar(50) DEFAULT NULL COMMENT '包规',
      `innerpack` decimal(22,5) DEFAULT NULL COMMENT '内包装换算率',
      `casecant` decimal(22,5) DEFAULT NULL COMMENT '件箱换算率',
      `pallet` decimal(22,5) DEFAULT NULL COMMENT '托盘换算率',
      PRIMARY KEY (`task_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='预作业作业队列'
    """

    __tablename__ = 'wops_prework_work_queue'

    task_id = Column(String(32), primary_key=True, comment='母任务编号')
    parent_task_id = Column(String(255), comment='上级任务，无上级任务则为空，多个上级任务用逗号分隔')
    command_type_code = Column(String(32), nullable=False, comment='指令类型编号')
    command_group_code = Column(String(32), nullable=False, comment='指令组编号')
    lpn = Column(String(32), nullable=False, comment='作业LPN')
    is_urgent = Column(Integer, comment='急料标识')
    sku = Column(String(32), nullable=False, comment='物料sku')
    origin_sku_num = Column(Integer, nullable=False, comment='初始PCS数')
    target_sku_num = Column(Integer, nullable=False, comment='最终PCS数')
    origin_pack_type = Column(Integer, nullable=False, comment='开始物料类型')
    target_pack_type = Column(Integer, nullable=False, comment='结束物料类型')
    origin_loc = Column(String(32), nullable=False, comment='开始货位')
    origin_loc_template_detailid = Column(String(32), comment='开始货位货格（针对柔性货位使用）')
    state = Column(Integer, comment='工单状态\r\n工单状态1 新建、 2:已排程、3、已下发、4已完成、5已取消')
    plan_begin = Column(DateTime, comment='计划开始时间')
    plan_end = Column(DateTime, comment='计划结束时间')
    wops_wavelet_orderid = Column(String(32), comment='小波次编号')
    wops_command_unit_routeid = Column(String(32), comment='作业路径编号')
    wops_vehicle_taskid = Column(String(32), comment='发车任务编号')
    wops_delivery_time_windowid = Column(String(32), nullable=False, comment='大波次编号')
    time_window_start_time = Column(DateTime, nullable=False, comment='时间窗开始时间')
    time_window_end_time = Column(DateTime, nullable=False, comment='世界窗结束时间')
    vehicle_task_begin_time = Column(DateTime, comment='装车开始时间')
    vehicle_task_end_time = Column(DateTime, comment='装车结束时间')
    add_date = Column(DateTime, nullable=False, comment='创建日期')
    edit_date = Column(DateTime, nullable=False, comment='编辑日期')
    loc_column = Column(Integer, comment='列')
    loc_row = Column(Integer, comment='货位行')
    template_id = Column(String(32), comment='模板编号')
    deliver_factory_code = Column(String(32))
    deliver_factory = Column(String(32))
    wops_prework_planid = Column(String(32), nullable=False)
    packkey = Column(String(50), comment='包规')
    innerpack = Column(DECIMAL(22, 5), comment='内包装换算率')
    casecant = Column(DECIMAL(22, 5), comment='件箱换算率')
    pallet = Column(DECIMAL(22, 5), comment='托盘换算率')
    lot = Column(String(256), comment='当前任务选中物料批次号')
    act_num = Column(Integer, comment='多批次栈板实际数量')


class TallyWorkQueue(Base):
    """
    CREATE TABLE `wops_tally_work_queue` (
      `task_id` varchar(32) NOT NULL COMMENT '母任务编号',
      `parent_task_id` varchar(255) DEFAULT NULL COMMENT '上级任务，无上级任务则为空，多个上级任务用逗号分隔',
      `command_type_code` varchar(32) NOT NULL COMMENT '指令类型编号',
      `command_group_code` varchar(32) NOT NULL COMMENT '指令组编号',
      `lpn` varchar(32) NOT NULL COMMENT '作业LPN',
      `is_urgent` int(10) DEFAULT NULL COMMENT '急料标识',
      `sku` varchar(32) NOT NULL COMMENT '物料sku',
      `origin_sku_num` int(10) NOT NULL,
      `target_sku_num` int(10) NOT NULL,
      `origin_pack_type` int(10) NOT NULL COMMENT '开始物料类型',
      `target_pack_type` int(10) NOT NULL COMMENT '结束物料类型',
      `origin_loc` varchar(32) NOT NULL COMMENT '开始货位',
      `origin_loc_template_detailid` varchar(32) DEFAULT NULL COMMENT '开始货位货格（针对柔性货位使用）',
      `state` int(10) DEFAULT NULL COMMENT '工单状态\r\n工单状态1 新建、 2:已排程、3、已下发、4已完成、5已取消',
      `plan_begin` datetime DEFAULT NULL COMMENT '计划开始时间',
      `plan_end` datetime DEFAULT NULL COMMENT '计划结束时间',
      `wops_wavelet_orderid` varchar(32) DEFAULT NULL COMMENT '小波次编号',
      `wops_command_unit_routeid` varchar(32) DEFAULT NULL COMMENT '作业路径编号',
      `wops_vehicle_taskid` varchar(32) DEFAULT NULL COMMENT '发车任务编号',
      `wops_delivery_time_windowid` varchar(32) NOT NULL COMMENT '大波次编号',
      `time_window_start_time` datetime NOT NULL COMMENT '时间窗开始时间',
      `time_window_end_time` datetime NOT NULL COMMENT '世界窗结束时间',
      `vehicle_task_begin_time` datetime DEFAULT NULL COMMENT '装车开始时间',
      `vehicle_task_end_time` datetime DEFAULT NULL COMMENT '装车结束时间',
      `add_date` datetime NOT NULL COMMENT '创建日期',
      `edit_date` datetime NOT NULL COMMENT '编辑日期',
      `loc_column` int(11) DEFAULT NULL COMMENT '列',
      `loc_row` int(11) DEFAULT NULL COMMENT '货位行',
      `template_id` varchar(32) DEFAULT NULL COMMENT '模板编号',
      `deliver_factory_code` varchar(32) DEFAULT NULL,
      `deliver_factory` varchar(32) DEFAULT NULL,
      `packkey` varchar(50) DEFAULT NULL COMMENT '包规',
      `innerpack` decimal(22,5) DEFAULT NULL COMMENT '内包装换算率',
      `casecant` decimal(22,5) DEFAULT NULL COMMENT '件箱换算率',
      `pallet` decimal(22,5) DEFAULT NULL COMMENT '托盘换算率',
      PRIMARY KEY (`task_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='理货作业队列'
    """
    __tablename__ = 'wops_tally_work_queue'

    task_id = Column(String(32), primary_key=True, comment='母任务编号')
    parent_task_id = Column(String(255), comment='上级任务，无上级任务则为空，多个上级任务用逗号分隔')
    command_type_code = Column(String(32), nullable=False, comment='指令类型编号')
    command_group_code = Column(String(32), nullable=False, comment='指令组编号')
    lpn = Column(String(32), nullable=False, comment='作业LPN')
    is_urgent = Column(Integer, comment='急料标识')
    sku = Column(String(32), nullable=False, comment='物料sku')
    origin_sku_num = Column(Integer, nullable=False, comment='初始PCS数')
    target_sku_num = Column(Integer, nullable=False, comment='最终PCS数')
    origin_pack_type = Column(Integer, nullable=False, comment='开始物料类型')
    target_pack_type = Column(Integer, nullable=False, comment='结束物料类型')
    origin_loc = Column(String(32), nullable=False, comment='开始货位')
    origin_loc_template_detailid = Column(String(32), comment='开始货位货格（针对柔性货位使用）')
    state = Column(Integer, comment='工单状态\r\n工单状态1 新建、 2:已排程、3、已下发、4已完成、5已取消')
    plan_begin = Column(DateTime, comment='计划开始时间')
    plan_end = Column(DateTime, comment='计划结束时间')
    wops_wavelet_orderid = Column(String(32), comment='小波次编号')
    wops_command_unit_routeid = Column(String(32), comment='作业路径编号')
    wops_vehicle_taskid = Column(String(32), comment='发车任务编号')
    wops_delivery_time_windowid = Column(String(32), nullable=False, comment='大波次编号')
    time_window_start_time = Column(DateTime, nullable=False, comment='时间窗开始时间')
    time_window_end_time = Column(DateTime, nullable=False, comment='世界窗结束时间')
    vehicle_task_begin_time = Column(DateTime, comment='装车开始时间')
    vehicle_task_end_time = Column(DateTime, comment='装车结束时间')
    add_date = Column(DateTime, nullable=False, comment='创建日期')
    edit_date = Column(DateTime, nullable=False, comment='编辑日期')
    loc_column = Column(Integer, comment='列')
    loc_row = Column(Integer, comment='货位行')
    template_id = Column(String(32), comment='模板编号')
    deliver_factory_code = Column(String(32))
    deliver_factory = Column(String(32))
    packkey = Column(String(50), comment='包规')
    innerpack = Column(DECIMAL(22, 5), comment='内包装换算率')
    casecant = Column(DECIMAL(22, 5), comment='件箱换算率')
    pallet = Column(DECIMAL(22, 5), comment='托盘换算率')


if __name__ == '__main__':
    with Session() as sess:
        for m in [DeliveryWorkQueue, InteriorWorkQueue, PreworkWorkQueue, TallyWorkQueue]:
            all_data = sess.query(m).all()
            print(f'{m.__name__} --> {[_.to_dict() for _ in all_data]}')
